package com.foreknow.demo4;

import java.util.Scanner;

/**
 *  定义一个方法：求1~10的和
 */
public class TestMethod2 {
    public static void sum(int n) {  //有几个需要用户输入的变量就定义几个形式参数
        int sum = 0;
        for (int a = 1;a<=n;a++) {
            sum += a;
        }
        System.out.println(sum);
    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        TestMethod2.sum(n);
    }
}




